package com.test.netty.ssl;

import com.test.netty.http.HttpServerHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.ssl.SslHandler;

import javax.net.ssl.SSLEngine;

public class SslServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();

        String cChatPath =  System.getProperty("user.dir")+"/src/main/java/com/zhaozhou/netty/demo/ssl/conf/oneway/clientStore.jks";
        String sChatPath = "d:\\test\\serverStore.jks";

        SSLEngine engine = SslOneWayContextFactory.getClientContext(cChatPath)
                .createSSLEngine();//创建SSLEngine
        engine.setUseClientMode(false);
        pipeline.addLast("ssl", new SslHandler(engine));


        System.out.println("ok~~~~");
    }

}
